//============================================================================
// Name        : csiena
// Author      : Josh Lospinoso
// Copyright   : MIT License
// Description : Austere, limited implementation of the R package RSiena in
//				 C++. Used for fast maximum likelihood and method of moments
//				 estimation of stochastic actor oriented models (SAOMs)
//				 without any frills or user experience niceties.
//============================================================================

#ifndef LINK_EVALUATION_H_
#define LINK_EVALUATION_H_
#include "globals.h"
#include "evaluation.h"

namespace csiena {
class LinkEvaluation : public Evaluation {
public:
	// Initializers
	LinkEvaluation(int actors);
	LinkEvaluation(const LinkEvaluation &donorEvaluation);
	virtual ~LinkEvaluation();

	// Accessors
	double getFij(int alter);
	double getExpFij(int alter);
	double getPij(int alter);
	double getBeta(int beta);
	void setBeta(int beta, double value);
	void incrementBeta(int beta, double value);
	double getPijDenominator();
	int getEgoIndex();
	int getActors();
	double getChangeStats(int beta, int alter);

	// Calculation methods -- Most computationally intensive!
	void preprocess(int i, Digraph* x);

	// Utility methods
	void print();
	bool isLinkEvaluation();

	// Methods for CUDA acceleration:
	#ifdef CUDA
	void checkForDevices();
	#endif

private:
	double *fij;
	double *expfij;
	double *pij;
	double *beta;
	double pijDenominator;
	void makeChangeStatsNegative(int alter);
	void setChangeStats(int beta, int alter, double value);
	void resetChangeStats();
	double *changeStats;
	int i;
	int actors;
};
}

#endif /* LINK_EVALUATION_H_ */
